(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.adapter=e()}})(function(){var e,t,r;return function(){function e(t,r,n){function i(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof require&&require;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var f=r[o]={exports:{}};t[o][0].call(f.exports,function(e){var r=t[o][1][e];return i(r||e)},f,f.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}return e}()({1:[function(e,t,r){"use strict";var n=e("./adapter_factory.js");var i=(0,n.adapterFactory)({window:typeof window==="undefined"?undefined:window});t.exports=i},{"./adapter_factory.js":2}],2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.adapterFactory=h;var n=e("./utils");var i=m(n);var a=e("./chrome/chrome_shim");var o=m(a);var s=e("./edge/edge_shim");var c=m(s);var d=e("./firefox/firefox_shim");var f=m(d);var p=e("./safari/safari_shim");var u=m(p);var l=e("./common_shim");var v=m(l);function m(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function h(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},t=e.window;var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{shimChrome:true,shimFirefox:true,shimEdge:true,shimSafari:true};var n=i.log;var a=i.detectBrowser(t);var s={browserDetails:a,commonShim:v,extractVersion:i.extractVersion,disableLog:i.disableLog,disableWarnings:i.disableWarnings};switch(a.browser){case"chrome":if(!o||!o.shimPeerConnection||!r.shimChrome){n("Chrome shim is not included in this adapter release.");return s}if(a.version===null){n("Chrome shim can not determine version, not shimming.");return s}n("adapter.js shimming chrome.");s.browserShim=o;o.shimGetUserMedia(t);o.shimMediaStream(t);o.shimPeerConnection(t);o.shimOnTrack(t);o.shimAddTrackRemoveTrack(t);o.shimGetSendersWithDtmf(t);o.shimGetStats(t);o.shimSenderReceiverGetStats(t);o.fixNegotiationNeeded(t);v.shimRTCIceCandidate(t);v.shimConnectionState(t);v.shimMaxMessageSize(t);v.shimSendThrowTypeError(t);v.removeAllowExtmapMixed(t);break;case"firefox":if(!f||!f.shimPeerConnection||!r.shimFirefox){n("Firefox shim is not included in this adapter release.");return s}n("adapter.js shimming firefox.");s.browserShim=f;f.shimGetUserMedia(t);f.shimPeerConnection(t);f.shimOnTrack(t);f.shimRemoveStream(t);f.shimSenderGetStats(t);f.shimReceiverGetStats(t);f.shimRTCDataChannel(t);f.shimAddTransceiver(t);f.shimGetParameters(t);f.shimCreateOffer(t);f.shimCreateAnswer(t);v.shimRTCIceCandidate(t);v.shimConnectionState(t);v.shimMaxMessageSize(t);v.shimSendThrowTypeError(t);break;case"edge":if(!c||!c.shimPeerConnection||!r.shimEdge){n("MS edge shim is not included in this adapter release.");return s}n("adapter.js shimming edge.");s.browserShim=c;c.shimGetUserMedia(t);c.shimGetDisplayMedia(t);c.shimPeerConnection(t);c.shimReplaceTrack(t);v.shimMaxMessageSize(t);v.shimSendThrowTypeError(t);break;case"safari":if(!u||!r.shimSafari){n("Safari shim is not included in this adapter release.");return s}n("adapter.js shimming safari.");s.browserShim=u;u.shimRTCIceServerUrls(t);u.shimCreateOfferLegacy(t);u.shimCallbacksAPI(t);u.shimLocalStreamsAPI(t);u.shimRemoteStreamsAPI(t);u.shimTrackEventTransceiver(t);u.shimGetUserMedia(t);u.shimAudioContext(t);v.shimRTCIceCandidate(t);v.shimMaxMessageSize(t);v.shimSendThrowTypeError(t);v.removeAllowExtmapMixed(t);break;default:n("Unsupported browser!");break}return s}},{"./chrome/chrome_shim":3,"./common_shim":6,"./edge/edge_shim":7,"./firefox/firefox_shim":11,"./safari/safari_shim":14,"./utils":15}],3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetDisplayMedia=r.shimGetUserMedia=undefined;var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:true,get:function e(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:true,get:function e(){return a.shimGetDisplayMedia}});r.shimMediaStream=f;r.shimOnTrack=p;r.shimGetSendersWithDtmf=u;r.shimGetStats=l;r.shimSenderReceiverGetStats=v;r.shimAddTrackRemoveTrackWithNative=m;r.shimAddTrackRemoveTrack=h;r.shimPeerConnection=y;r.fixNegotiationNeeded=g;var o=e("../utils.js");var s=c(o);function c(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function d(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function f(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function p(e){if((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function e(){return this._ontrack},set:function e(t){if(this._ontrack){this.removeEventListener("track",this._ontrack)}this.addEventListener("track",this._ontrack=t)},enumerable:true,configurable:true});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function r(){var n=this;if(!this._ontrackpoly){this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",function(r){var i=void 0;if(e.RTCPeerConnection.prototype.getReceivers){i=n.getReceivers().find(function(e){return e.track&&e.track.id===r.track.id})}else{i={track:r.track}}var a=new Event("track");a.track=r.track;a.receiver=i;a.transceiver={receiver:i};a.streams=[t.stream];n.dispatchEvent(a)});t.stream.getTracks().forEach(function(r){var i=void 0;if(e.RTCPeerConnection.prototype.getReceivers){i=n.getReceivers().find(function(e){return e.track&&e.track.id===r.id})}else{i={track:r}}var a=new Event("track");a.track=r;a.receiver=i;a.transceiver={receiver:i};a.streams=[t.stream];n.dispatchEvent(a)})};this.addEventListener("addstream",this._ontrackpoly)}return t.apply(this,arguments)}}else{s.wrapPeerConnectionEvent(e,"track",function(e){if(!e.transceiver){Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}})}return e})}}function u(e){if((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function e(t,r){return{track:r,get dtmf(){if(this._dtmf===undefined){if(r.kind==="audio"){this._dtmf=t.createDTMFSender(r)}else{this._dtmf=null}}return this._dtmf},_pc:t}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function e(){this._senders=this._senders||[];return this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function e(n,i){var a=r.apply(this,arguments);if(!a){a=t(this,n);this._senders.push(a)}return a};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function e(t){i.apply(this,arguments);var r=this._senders.indexOf(t);if(r!==-1){this._senders.splice(r,1)}}}var a=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function e(r){var n=this;this._senders=this._senders||[];a.apply(this,[r]);r.getTracks().forEach(function(e){n._senders.push(t(n,e))})};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function e(t){var r=this;this._senders=this._senders||[];o.apply(this,[t]);t.getTracks().forEach(function(e){var t=r._senders.find(function(t){return t.track===e});if(t){r._senders.splice(r._senders.indexOf(t),1)}})}}else if((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function e(){var t=this;var r=s.apply(this,[]);r.forEach(function(e){return e._pc=t});return r};Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function e(){if(this._dtmf===undefined){if(this.track.kind==="audio"){this._dtmf=this._pc.createDTMFSender(this.track)}else{this._dtmf=null}}return this._dtmf}})}}function l(e){if(!e.RTCPeerConnection){return}var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function e(){var r=this;var n=Array.prototype.slice.call(arguments),i=n[0],a=n[1],o=n[2];if(arguments.length>0&&typeof i==="function"){return t.apply(this,arguments)}if(t.length===0&&(arguments.length===0||typeof i!=="function")){return t.apply(this,[])}var s=function e(t){var r={};var n=t.result();n.forEach(function(e){var t={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(r){t[r]=e.stat(r)});r[t.id]=t});return r};var c=function e(t){return new Map(Object.keys(t).map(function(e){return[e,t[e]]}))};if(arguments.length>=2){var d=function e(t){a(c(s(t)))};return t.apply(this,[d,i])}return new Promise(function(e,n){t.apply(r,[function(t){e(c(s(t)))},n])}).then(a,o)}}function v(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver)){return}if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;if(t){e.RTCPeerConnection.prototype.getSenders=function e(){var r=this;var n=t.apply(this,[]);n.forEach(function(e){return e._pc=r});return n}}var r=e.RTCPeerConnection.prototype.addTrack;if(r){e.RTCPeerConnection.prototype.addTrack=function e(){var t=r.apply(this,arguments);t._pc=this;return t}}e.RTCRtpSender.prototype.getStats=function e(){var t=this;return this._pc.getStats().then(function(e){return s.filterStats(e,t.track,true)})}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var i=e.RTCPeerConnection.prototype.getReceivers;if(i){e.RTCPeerConnection.prototype.getReceivers=function e(){var t=this;var r=i.apply(this,[]);r.forEach(function(e){return e._pc=t});return r}}s.wrapPeerConnectionEvent(e,"track",function(e){e.receiver._pc=e.srcElement;return e});e.RTCRtpReceiver.prototype.getStats=function e(){var t=this;return this._pc.getStats().then(function(e){return s.filterStats(e,t.track,false)})}}if(!("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype)){return}var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function t(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var r=arguments[0];var n=void 0;var i=void 0;var o=void 0;this.getSenders().forEach(function(e){if(e.track===r){if(n){o=true}else{n=e}}});this.getReceivers().forEach(function(e){if(e.track===r){if(i){o=true}else{i=e}}return e.track===r});if(o||n&&i){return Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError"))}else if(n){return n.getStats()}else if(i){return i.getStats()}return Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}}function m(e){e.RTCPeerConnection.prototype.getLocalStreams=function e(){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};return Object.keys(this._shimmedLocalStreams).map(function(e){return t._shimmedLocalStreams[e][0]})};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function e(r,n){if(!n){return t.apply(this,arguments)}this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);if(!this._shimmedLocalStreams[n.id]){this._shimmedLocalStreams[n.id]=[n,i]}else if(this._shimmedLocalStreams[n.id].indexOf(i)===-1){this._shimmedLocalStreams[n.id].push(i)}return i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function e(t){var n=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};t.getTracks().forEach(function(e){var t=n.getSenders().find(function(t){return t.track===e});if(t){throw new DOMException("Track already exists.","InvalidAccessError")}});var i=this.getSenders();r.apply(this,arguments);var a=this.getSenders().filter(function(e){return i.indexOf(e)===-1});this._shimmedLocalStreams[t.id]=[t].concat(a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function e(t){this._shimmedLocalStreams=this._shimmedLocalStreams||{};delete this._shimmedLocalStreams[t.id];return n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function e(t){var r=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{};if(t){Object.keys(this._shimmedLocalStreams).forEach(function(e){var n=r._shimmedLocalStreams[e].indexOf(t);if(n!==-1){r._shimmedLocalStreams[e].splice(n,1)}if(r._shimmedLocalStreams[e].length===1){delete r._shimmedLocalStreams[e]}})}return i.apply(this,arguments)}}function h(e){if(!e.RTCPeerConnection){return}var t=s.detectBrowser(e);if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65){return m(e)}var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function e(){var t=this;var n=r.apply(this);this._reverseStreams=this._reverseStreams||{};return n.map(function(e){return t._reverseStreams[e.id]})};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function t(r){var i=this;this._streams=this._streams||{};this._reverseStreams=this._reverseStreams||{};r.getTracks().forEach(function(e){var t=i.getSenders().find(function(t){return t.track===e});if(t){throw new DOMException("Track already exists.","InvalidAccessError")}});if(!this._reverseStreams[r.id]){var a=new e.MediaStream(r.getTracks());this._streams[r.id]=a;this._reverseStreams[a.id]=r;r=a}n.apply(this,[r])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function e(t){this._streams=this._streams||{};this._reverseStreams=this._reverseStreams||{};i.apply(this,[this._streams[t.id]||t]);delete this._reverseStreams[this._streams[t.id]?this._streams[t.id].id:t.id];delete this._streams[t.id]};e.RTCPeerConnection.prototype.addTrack=function t(r,n){var i=this;if(this.signalingState==="closed"){throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError")}var a=[].slice.call(arguments,1);if(a.length!==1||!a[0].getTracks().find(function(e){return e===r})){throw new DOMException("The adapter.js addTrack polyfill only supports a single "+" stream which is associated with the specified track.","NotSupportedError")}var o=this.getSenders().find(function(e){return e.track===r});if(o){throw new DOMException("Track already exists.","InvalidAccessError")}this._streams=this._streams||{};this._reverseStreams=this._reverseStreams||{};var s=this._streams[n.id];if(s){s.addTrack(r);Promise.resolve().then(function(){i.dispatchEvent(new Event("negotiationneeded"))})}else{var c=new e.MediaStream([r]);this._streams[n.id]=c;this._reverseStreams[c.id]=n;this.addStream(c)}return this.getSenders().find(function(e){return e.track===r})};function a(e,t){var r=t.sdp;Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t];var i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)});return new RTCSessionDescription({type:t.type,sdp:r})}function o(e,t){var r=t.sdp;Object.keys(e._reverseStreams||[]).forEach(function(t){var n=e._reverseStreams[t];var i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)});return new RTCSessionDescription({type:t.type,sdp:r})}["createOffer","createAnswer"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];var n=d({},t,function(){var e=this;var t=arguments;var n=arguments.length&&typeof arguments[0]==="function";if(n){return r.apply(this,[function(r){var n=a(e,r);t[0].apply(null,[n])},function(e){if(t[1]){t[1].apply(null,e)}},arguments[2]])}return r.apply(this,arguments).then(function(t){return a(e,t)})});e.RTCPeerConnection.prototype[t]=n[t]});var c=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function e(){if(!arguments.length||!arguments[0].type){return c.apply(this,arguments)}arguments[0]=o(this,arguments[0]);return c.apply(this,arguments)};var f=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function e(){var t=f.get.apply(this);if(t.type===""){return t}return a(this,t)}});e.RTCPeerConnection.prototype.removeTrack=function e(t){var r=this;if(this.signalingState==="closed"){throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError")}if(!t._pc){throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack "+"does not implement interface RTCRtpSender.","TypeError")}var n=t._pc===this;if(!n){throw new DOMException("Sender was not created by this connection.","InvalidAccessError")}this._streams=this._streams||{};var i=void 0;Object.keys(this._streams).forEach(function(e){var n=r._streams[e].getTracks().find(function(e){return t.track===e});if(n){i=r._streams[e]}});if(i){if(i.getTracks().length===1){this.removeStream(this._reverseStreams[i.id])}else{i.removeTrack(t.track)}this.dispatchEvent(new Event("negotiationneeded"))}}}function y(e){var t=s.detectBrowser(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection){e.RTCPeerConnection=e.webkitRTCPeerConnection}if(!e.RTCPeerConnection){return}var r=e.RTCPeerConnection.prototype.addIceCandidate.length===0;if(t.version<53){["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];var n=d({},t,function(){arguments[0]=new(t==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]);return r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})}var n=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function e(){if(!r&&!arguments[0]){if(arguments[1]){arguments[1].apply(null)}return Promise.resolve()}if(t.version<78&&arguments[0]&&arguments[0].candidate===""){return Promise.resolve()}return n.apply(this,arguments)}}function g(e){var t=s.detectBrowser(e);s.wrapPeerConnectionEvent(e,"negotiationneeded",function(e){var r=e.target;if(t.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b"){if(r.signalingState!=="stable"){return}}return e})}},{"../utils.js":15,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetDisplayMedia=n;function n(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices){return}if(!e.navigator.mediaDevices){return}if(typeof t!=="function"){console.error("shimGetDisplayMedia: getSourceId argument is not "+"a function");return}e.navigator.mediaDevices.getDisplayMedia=function r(n){return t(n).then(function(t){var r=n.video&&n.video.width;var i=n.video&&n.video.height;var a=n.video&&n.video.frameRate;n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}};if(r){n.video.mandatory.maxWidth=r}if(i){n.video.mandatory.maxHeight=i}return e.navigator.mediaDevices.getUserMedia(n)})}}},{}],5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.shimGetUserMedia=c;var i=e("../utils.js");var a=o(i);function o(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}var s=a.log;function c(e){var t=e&&e.navigator;if(!t.mediaDevices){return}var r=a.detectBrowser(e);var i=function e(t){if((typeof t==="undefined"?"undefined":n(t))!=="object"||t.mandatory||t.optional){return t}var r={};Object.keys(t).forEach(function(e){if(e==="require"||e==="advanced"||e==="mediaSource"){return}var i=n(t[e])==="object"?t[e]:{ideal:t[e]};if(i.exact!==undefined&&typeof i.exact==="number"){i.min=i.max=i.exact}var a=function e(t,r){if(t){return t+r.charAt(0).toUpperCase()+r.slice(1)}return r==="deviceId"?"sourceId":r};if(i.ideal!==undefined){r.optional=r.optional||[];var o={};if(typeof i.ideal==="number"){o[a("min",e)]=i.ideal;r.optional.push(o);o={};o[a("max",e)]=i.ideal;r.optional.push(o)}else{o[a("",e)]=i.ideal;r.optional.push(o)}}if(i.exact!==undefined&&typeof i.exact!=="number"){r.mandatory=r.mandatory||{};r.mandatory[a("",e)]=i.exact}else{["min","max"].forEach(function(t){if(i[t]!==undefined){r.mandatory=r.mandatory||{};r.mandatory[a(t,e)]=i[t]}})}});if(t.advanced){r.optional=(r.optional||[]).concat(t.advanced)}return r};var o=function e(a,o){if(r.version>=61){return o(a)}a=JSON.parse(JSON.stringify(a));if(a&&n(a.audio)==="object"){var c=function e(t,r,n){if(r in t&&!(n in t)){t[n]=t[r];delete t[r]}};a=JSON.parse(JSON.stringify(a));c(a.audio,"autoGainControl","googAutoGainControl");c(a.audio,"noiseSuppression","googNoiseSuppression");a.audio=i(a.audio)}if(a&&n(a.video)==="object"){var d=a.video.facingMode;d=d&&((typeof d==="undefined"?"undefined":n(d))==="object"?d:{ideal:d});var f=r.version<66;if(d&&(d.exact==="user"||d.exact==="environment"||d.ideal==="user"||d.ideal==="environment")&&!(t.mediaDevices.getSupportedConstraints&&t.mediaDevices.getSupportedConstraints().facingMode&&!f)){delete a.video.facingMode;var p=void 0;if(d.exact==="environment"||d.ideal==="environment"){p=["back","rear"]}else if(d.exact==="user"||d.ideal==="user"){p=["front"]}if(p){return t.mediaDevices.enumerateDevices().then(function(e){e=e.filter(function(e){return e.kind==="videoinput"});var t=e.find(function(e){return p.some(function(t){return e.label.toLowerCase().includes(t)})});if(!t&&e.length&&p.includes("back")){t=e[e.length-1]}if(t){a.video.deviceId=d.exact?{exact:t.deviceId}:{ideal:t.deviceId}}a.video=i(a.video);s("chrome: "+JSON.stringify(a));return o(a)})}}a.video=i(a.video)}s("chrome: "+JSON.stringify(a));return o(a)};var c=function e(t){if(r.version>=64){return t}return{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[t.name]||t.name,message:t.message,constraint:t.constraint||t.constraintName,toString:function e(){return this.name+(this.message&&": ")+this.message}}};var d=function e(r,n,i){o(r,function(e){t.webkitGetUserMedia(e,n,function(e){if(i){i(c(e))}})})};t.getUserMedia=d.bind(t);if(t.mediaDevices.getUserMedia){var f=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return o(e,function(e){return f(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length){t.getTracks().forEach(function(e){e.stop()});throw new DOMException("","NotFoundError")}return t},function(e){return Promise.reject(c(e))})})}}}},{"../utils.js":15}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.shimRTCIceCandidate=f;r.shimMaxMessageSize=p;r.shimSendThrowTypeError=u;r.shimConnectionState=l;r.removeAllowExtmapMixed=v;var i=e("sdp");var a=d(i);var o=e("./utils");var s=c(o);function c(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function d(e){return e&&e.__esModule?e:{default:e}}function f(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype){return}var t=e.RTCIceCandidate;e.RTCIceCandidate=function e(r){if((typeof r==="undefined"?"undefined":n(r))==="object"&&r.candidate&&r.candidate.indexOf("a=")===0){r=JSON.parse(JSON.stringify(r));r.candidate=r.candidate.substr(2)}if(r.candidate&&r.candidate.length){var i=new t(r);var o=a.default.parseCandidate(r.candidate);var s=Object.assign(i,o);s.toJSON=function e(){return{candidate:s.candidate,sdpMid:s.sdpMid,sdpMLineIndex:s.sdpMLineIndex,usernameFragment:s.usernameFragment}};return s}return new t(r)};e.RTCIceCandidate.prototype=t.prototype;s.wrapPeerConnectionEvent(e,"icecandidate",function(t){if(t.candidate){Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"})}return t})}function p(e){if(!e.RTCPeerConnection){return}var t=s.detectBrowser(e);if(!("sctp"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function e(){return typeof this._sctp==="undefined"?null:this._sctp}})}var r=function e(t){if(!t||!t.sdp){return false}var r=a.default.splitSections(t.sdp);r.shift();return r.some(function(e){var t=a.default.parseMLine(e);return t&&t.kind==="application"&&t.protocol.indexOf("SCTP")!==-1})};var n=function e(t){var r=t.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(r===null||r.length<2){return-1}var n=parseInt(r[1],10);return n!==n?-1:n};var i=function e(r){var n=65536;if(t.browser==="firefox"){if(t.version<57){if(r===-1){n=16384}else{n=2147483637}}else if(t.version<60){n=t.version===57?65535:65536}else{n=2147483637}}return n};var o=function e(r,n){var i=65536;if(t.browser==="firefox"&&t.version===57){i=65535}var o=a.default.matchPrefix(r.sdp,"a=max-message-size:");if(o.length>0){i=parseInt(o[0].substr(19),10)}else if(t.browser==="firefox"&&n!==-1){i=2147483637}return i};var c=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function e(){this._sctp=null;if(t.browser==="chrome"&&t.version>=76){var a=this.getConfiguration(),s=a.sdpSemantics;if(s==="plan-b"){Object.defineProperty(this,"sctp",{get:function e(){return typeof this._sctp==="undefined"?null:this._sctp},enumerable:true,configurable:true})}}if(r(arguments[0])){var d=n(arguments[0]);var f=i(d);var p=o(arguments[0],d);var u=void 0;if(f===0&&p===0){u=Number.POSITIVE_INFINITY}else if(f===0||p===0){u=Math.max(f,p)}else{u=Math.min(f,p)}var l={};Object.defineProperty(l,"maxMessageSize",{get:function e(){return u}});this._sctp=l}return c.apply(this,arguments)}}function u(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype)){return}function t(e,t){var r=e.send;e.send=function n(){var i=arguments[0];var a=i.length||i.size||i.byteLength;if(e.readyState==="open"&&t.sctp&&a>t.sctp.maxMessageSize){throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)")}return r.apply(e,arguments)}}var r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function e(){var n=r.apply(this,arguments);t(n,this);return n};s.wrapPeerConnectionEvent(e,"datachannel",function(e){t(e.channel,e.target);return e})}function l(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype){return}var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function e(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:true,configurable:true});Object.defineProperty(t,"onconnectionstatechange",{get:function e(){return this._onconnectionstatechange||null},set:function e(t){if(this._onconnectionstatechange){this.removeEventListener("connectionstatechange",this._onconnectionstatechange);delete this._onconnectionstatechange}if(t){this.addEventListener("connectionstatechange",this._onconnectionstatechange=t)}},enumerable:true,configurable:true});["setLocalDescription","setRemoteDescription"].forEach(function(e){var r=t[e];t[e]=function(){if(!this._connectionstatechangepoly){this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e};this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)}return r.apply(this,arguments)}})}function v(e){if(!e.RTCPeerConnection){return}var t=s.detectBrowser(e);if(t.browser==="chrome"&&t.version>=71){return}if(t.browser==="safari"&&t.version>=605){return}var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function e(t){if(t&&t.sdp&&t.sdp.indexOf("\na=extmap-allow-mixed")!==-1){t.sdp=t.sdp.split("\n").filter(function(e){return e.trim()!=="a=extmap-allow-mixed"}).join("\n")}return r.apply(this,arguments)}}},{"./utils":15,sdp:17}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetDisplayMedia=r.shimGetUserMedia=undefined;var n=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:true,get:function e(){return n.shimGetUserMedia}});var i=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:true,get:function e(){return i.shimGetDisplayMedia}});r.shimPeerConnection=u;r.shimReplaceTrack=l;var a=e("../utils");var o=p(a);var s=e("./filtericeservers");var c=e("rtcpeerconnection-shim");var d=f(c);function f(e){return e&&e.__esModule?e:{default:e}}function p(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function u(e){var t=o.detectBrowser(e);if(e.RTCIceGatherer){if(!e.RTCIceCandidate){e.RTCIceCandidate=function e(t){return t}}if(!e.RTCSessionDescription){e.RTCSessionDescription=function e(t){return t}}if(t.version<15025){var r=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function e(t){r.set.call(this,t);var n=new Event("enabled");n.enabled=t;this.dispatchEvent(n)}})}}if(e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function t(){if(this._dtmf===undefined){if(this.track.kind==="audio"){this._dtmf=new e.RTCDtmfSender(this)}else if(this.track.kind==="video"){this._dtmf=null}}return this._dtmf}})}if(e.RTCDtmfSender&&!e.RTCDTMFSender){e.RTCDTMFSender=e.RTCDtmfSender}var n=(0,d.default)(e,t.version);e.RTCPeerConnection=function e(r){if(r&&r.iceServers){r.iceServers=(0,s.filterIceServers)(r.iceServers,t.version);o.log("ICE servers after filtering:",r.iceServers)}return new n(r)};e.RTCPeerConnection.prototype=n.prototype}function l(e){if(e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)){e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack}}},{"../utils":15,"./filtericeservers":8,"./getdisplaymedia":9,"./getusermedia":10,"rtcpeerconnection-shim":16}],8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.filterIceServers=o;var n=e("../utils");var i=a(n);function a(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function o(e,t){var r=false;e=JSON.parse(JSON.stringify(e));return e.filter(function(e){if(e&&(e.urls||e.url)){var t=e.urls||e.url;if(e.url&&!e.urls){i.deprecated("RTCIceServer.url","RTCIceServer.urls")}var n=typeof t==="string";if(n){t=[t]}t=t.filter(function(e){if(e.indexOf("stun:")===0){return false}var t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");if(t&&!r){r=true;return true}return t&&!r});delete e.url;e.urls=n?t[0]:t;return!!t.length}})}},{"../utils":15}],9:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetDisplayMedia=n;function n(e){if(!("getDisplayMedia"in e.navigator)){return}if(!e.navigator.mediaDevices){return}if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices){return}e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)}},{}],10:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetUserMedia=n;function n(e){var t=e&&e.navigator;var r=function e(t){return{name:{PermissionDeniedError:"NotAllowedError"}[t.name]||t.name,message:t.message,constraint:t.constraint,toString:function e(){return this.name}}};var n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return n(e).catch(function(e){return Promise.reject(r(e))})}}},{}],11:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetDisplayMedia=r.shimGetUserMedia=undefined;var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var i=e("./getusermedia");Object.defineProperty(r,"shimGetUserMedia",{enumerable:true,get:function e(){return i.shimGetUserMedia}});var a=e("./getdisplaymedia");Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:true,get:function e(){return a.shimGetDisplayMedia}});r.shimOnTrack=f;r.shimPeerConnection=p;r.shimSenderGetStats=u;r.shimReceiverGetStats=l;r.shimRemoveStream=v;r.shimRTCDataChannel=m;r.shimAddTransceiver=h;r.shimGetParameters=y;r.shimCreateOffer=g;r.shimCreateAnswer=C;var o=e("../utils");var s=c(o);function c(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function d(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}function f(e){if((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)){Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function e(){return{receiver:this.receiver}}})}}function p(e){var t=s.detectBrowser(e);if((typeof e==="undefined"?"undefined":n(e))!=="object"||!(e.RTCPeerConnection||e.mozRTCPeerConnection)){return}if(!e.RTCPeerConnection&&e.mozRTCPeerConnection){e.RTCPeerConnection=e.mozRTCPeerConnection}if(t.version<53){["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){var r=e.RTCPeerConnection.prototype[t];var n=d({},t,function(){arguments[0]=new(t==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]);return r.apply(this,arguments)});e.RTCPeerConnection.prototype[t]=n[t]})}if(t.version<68){var r=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function e(){if(!arguments[0]){if(arguments[1]){arguments[1].apply(null)}return Promise.resolve()}if(arguments[0]&&arguments[0].candidate===""){return Promise.resolve()}return r.apply(this,arguments)}}var i={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"};var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function e(){var r=Array.prototype.slice.call(arguments),n=r[0],o=r[1],s=r[2];return a.apply(this,[n||null]).then(function(e){if(t.version<53&&!o){try{e.forEach(function(e){e.type=i[e.type]||e.type})}catch(t){if(t.name!=="TypeError"){throw t}e.forEach(function(t,r){e.set(r,Object.assign({},t,{type:i[t.type]||t.type}))})}}return e}).then(o,s)}}function u(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection&&e.RTCRtpSender)){return}if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype){return}var t=e.RTCPeerConnection.prototype.getSenders;if(t){e.RTCPeerConnection.prototype.getSenders=function e(){var r=this;var n=t.apply(this,[]);n.forEach(function(e){return e._pc=r});return n}}var r=e.RTCPeerConnection.prototype.addTrack;if(r){e.RTCPeerConnection.prototype.addTrack=function e(){var t=r.apply(this,arguments);t._pc=this;return t}}e.RTCRtpSender.prototype.getStats=function e(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function l(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection&&e.RTCRtpSender)){return}if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype){return}var t=e.RTCPeerConnection.prototype.getReceivers;if(t){e.RTCPeerConnection.prototype.getReceivers=function e(){var r=this;var n=t.apply(this,[]);n.forEach(function(e){return e._pc=r});return n}}s.wrapPeerConnectionEvent(e,"track",function(e){e.receiver._pc=e.srcElement;return e});e.RTCRtpReceiver.prototype.getStats=function e(){return this._pc.getStats(this.track)}}function v(e){if(!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype){return}e.RTCPeerConnection.prototype.removeStream=function e(t){var r=this;s.deprecated("removeStream","removeTrack");this.getSenders().forEach(function(e){if(e.track&&t.getTracks().includes(e.track)){r.removeTrack(e)}})}}function m(e){if(e.DataChannel&&!e.RTCDataChannel){e.RTCDataChannel=e.DataChannel}}function h(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection)){return}var t=e.RTCPeerConnection.prototype.addTransceiver;if(t){e.RTCPeerConnection.prototype.addTransceiver=function e(){this.setParametersPromises=[];var r=arguments[1];var n=r&&"sendEncodings"in r;if(n){r.sendEncodings.forEach(function(e){if("rid"in e){var t=/^[a-z0-9]{0,16}$/i;if(!t.test(e.rid)){throw new TypeError("Invalid RID value provided.")}}if("scaleResolutionDownBy"in e){if(!(parseFloat(e.scaleResolutionDownBy)>=1)){throw new RangeError("scale_resolution_down_by must be >= 1.0")}}if("maxFramerate"in e){if(!(parseFloat(e.maxFramerate)>=0)){throw new RangeError("max_framerate must be >= 0.0")}}})}var i=t.apply(this,arguments);if(n){var a=i.sender;var o=a.getParameters();if(!("encodings"in o)||o.encodings.length===1&&Object.keys(o.encodings[0]).length===0){o.encodings=r.sendEncodings;a.sendEncodings=r.sendEncodings;this.setParametersPromises.push(a.setParameters(o).then(function(){delete a.sendEncodings}).catch(function(){delete a.sendEncodings}))}}return i}}}function y(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCRtpSender)){return}var t=e.RTCRtpSender.prototype.getParameters;if(t){e.RTCRtpSender.prototype.getParameters=function e(){var r=t.apply(this,arguments);if(!("encodings"in r)){r.encodings=[].concat(this.sendEncodings||[{}])}return r}}}function g(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection)){return}var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function e(){var r=this,n=arguments;if(this.setParametersPromises&&this.setParametersPromises.length){return Promise.all(this.setParametersPromises).then(function(){return t.apply(r,n)}).finally(function(){r.setParametersPromises=[]})}return t.apply(this,arguments)}}function C(e){if(!((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCPeerConnection)){return}var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function e(){var r=this,n=arguments;if(this.setParametersPromises&&this.setParametersPromises.length){return Promise.all(this.setParametersPromises).then(function(){return t.apply(r,n)}).finally(function(){r.setParametersPromises=[]})}return t.apply(this,arguments)}}},{"../utils":15,"./getdisplaymedia":12,"./getusermedia":13}],12:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});r.shimGetDisplayMedia=n;function n(e,t){if(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices){return}if(!e.navigator.mediaDevices){return}e.navigator.mediaDevices.getDisplayMedia=function r(n){if(!(n&&n.video)){var i=new DOMException("getDisplayMedia without video "+"constraints is undefined");i.name="NotFoundError";i.code=8;return Promise.reject(i)}if(n.video===true){n.video={mediaSource:t}}else{n.video.mediaSource=t}return e.navigator.mediaDevices.getUserMedia(n)}}},{}],13:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.shimGetUserMedia=s;var i=e("../utils");var a=o(i);function o(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function s(e){var t=a.detectBrowser(e);var r=e&&e.navigator;var i=e&&e.MediaStreamTrack;r.getUserMedia=function(e,t,n){a.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia");r.mediaDevices.getUserMedia(e).then(t,n)};if(!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var o=function e(t,r,n){if(r in t&&!(n in t)){t[n]=t[r];delete t[r]}};var s=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){if((typeof e==="undefined"?"undefined":n(e))==="object"&&n(e.audio)==="object"){e=JSON.parse(JSON.stringify(e));o(e.audio,"autoGainControl","mozAutoGainControl");o(e.audio,"noiseSuppression","mozNoiseSuppression")}return s(e)};if(i&&i.prototype.getSettings){var c=i.prototype.getSettings;i.prototype.getSettings=function(){var e=c.apply(this,arguments);o(e,"mozAutoGainControl","autoGainControl");o(e,"mozNoiseSuppression","noiseSuppression");return e}}if(i&&i.prototype.applyConstraints){var d=i.prototype.applyConstraints;i.prototype.applyConstraints=function(e){if(this.kind==="audio"&&(typeof e==="undefined"?"undefined":n(e))==="object"){e=JSON.parse(JSON.stringify(e));o(e,"autoGainControl","mozAutoGainControl");o(e,"noiseSuppression","mozNoiseSuppression")}return d.apply(this,[e])}}}}},{"../utils":15}],14:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.shimLocalStreamsAPI=s;r.shimRemoteStreamsAPI=c;r.shimCallbacksAPI=d;r.shimGetUserMedia=f;r.shimConstraints=p;r.shimRTCIceServerUrls=u;r.shimTrackEventTransceiver=l;r.shimCreateOfferLegacy=v;r.shimAudioContext=m;var i=e("../utils");var a=o(i);function o(e){if(e&&e.__esModule){return e}else{var t={};if(e!=null){for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t[r]=e[r]}}t.default=e;return t}}function s(e){if((typeof e==="undefined"?"undefined":n(e))!=="object"||!e.RTCPeerConnection){return}if(!("getLocalStreams"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getLocalStreams=function e(){if(!this._localStreams){this._localStreams=[]}return this._localStreams}}if(!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function e(r){var n=this;if(!this._localStreams){this._localStreams=[]}if(!this._localStreams.includes(r)){this._localStreams.push(r)}r.getAudioTracks().forEach(function(e){return t.call(n,e,r)});r.getVideoTracks().forEach(function(e){return t.call(n,e,r)})};e.RTCPeerConnection.prototype.addTrack=function e(r){var n=this;for(var i=arguments.length,a=Array(i>1?i-1:0),o=1;o<i;o++){a[o-1]=arguments[o]}if(a){a.forEach(function(e){if(!n._localStreams){n._localStreams=[e]}else if(!n._localStreams.includes(e)){n._localStreams.push(e)}})}return t.apply(this,arguments)}}if(!("removeStream"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.removeStream=function e(t){var r=this;if(!this._localStreams){this._localStreams=[]}var n=this._localStreams.indexOf(t);if(n===-1){return}this._localStreams.splice(n,1);var i=t.getTracks();this.getSenders().forEach(function(e){if(i.includes(e.track)){r.removeTrack(e)}})}}}function c(e){if((typeof e==="undefined"?"undefined":n(e))!=="object"||!e.RTCPeerConnection){return}if(!("getRemoteStreams"in e.RTCPeerConnection.prototype)){e.RTCPeerConnection.prototype.getRemoteStreams=function e(){return this._remoteStreams?this._remoteStreams:[]}}if(!("onaddstream"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function e(){return this._onaddstream},set:function e(t){var r=this;if(this._onaddstream){this.removeEventListener("addstream",this._onaddstream);this.removeEventListener("track",this._onaddstreampoly)}this.addEventListener("addstream",this._onaddstream=t);this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(function(e){if(!r._remoteStreams){r._remoteStreams=[]}if(r._remoteStreams.includes(e)){return}r._remoteStreams.push(e);var t=new Event("addstream");t.stream=e;r.dispatchEvent(t)})})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function e(){var r=this;if(!this._onaddstreampoly){this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach(function(e){if(!r._remoteStreams){r._remoteStreams=[]}if(r._remoteStreams.indexOf(e)>=0){return}r._remoteStreams.push(e);var t=new Event("addstream");t.stream=e;r.dispatchEvent(t)})})}return t.apply(r,arguments)}}}function d(e){if((typeof e==="undefined"?"undefined":n(e))!=="object"||!e.RTCPeerConnection){return}var t=e.RTCPeerConnection.prototype;var r=t.createOffer;var i=t.createAnswer;var a=t.setLocalDescription;var o=t.setRemoteDescription;var s=t.addIceCandidate;t.createOffer=function e(t,n){var i=arguments.length>=2?arguments[2]:arguments[0];var a=r.apply(this,[i]);if(!n){return a}a.then(t,n);return Promise.resolve()};t.createAnswer=function e(t,r){var n=arguments.length>=2?arguments[2]:arguments[0];var a=i.apply(this,[n]);if(!r){return a}a.then(t,r);return Promise.resolve()};var c=function e(t,r,n){var i=a.apply(this,[t]);if(!n){return i}i.then(r,n);return Promise.resolve()};t.setLocalDescription=c;c=function e(t,r,n){var i=o.apply(this,[t]);if(!n){return i}i.then(r,n);return Promise.resolve()};t.setRemoteDescription=c;c=function e(t,r,n){var i=s.apply(this,[t]);if(!n){return i}i.then(r,n);return Promise.resolve()};t.addIceCandidate=c}function f(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices;var n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(p(e))}}if(!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia){t.getUserMedia=function e(r,n,i){t.mediaDevices.getUserMedia(r).then(n,i)}.bind(t)}}function p(e){if(e&&e.video!==undefined){return Object.assign({},e,{video:a.compactObject(e.video)})}return e}function u(e){if(!e.RTCPeerConnection){return}var t=e.RTCPeerConnection;e.RTCPeerConnection=function e(r,n){if(r&&r.iceServers){var i=[];for(var o=0;o<r.iceServers.length;o++){var s=r.iceServers[o];if(!s.hasOwnProperty("urls")&&s.hasOwnProperty("url")){a.deprecated("RTCIceServer.url","RTCIceServer.urls");s=JSON.parse(JSON.stringify(s));s.urls=s.url;delete s.url;i.push(s)}else{i.push(r.iceServers[o])}}r.iceServers=i}return new t(r,n)};e.RTCPeerConnection.prototype=t.prototype;if("generateCertificate"in t){Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function e(){return t.generateCertificate}})}}function l(e){if((typeof e==="undefined"?"undefined":n(e))==="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)){Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function e(){return{receiver:this.receiver}}})}}function v(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function e(r){if(r){if(typeof r.offerToReceiveAudio!=="undefined"){r.offerToReceiveAudio=!!r.offerToReceiveAudio}var n=this.getTransceivers().find(function(e){return e.receiver.track.kind==="audio"});if(r.offerToReceiveAudio===false&&n){if(n.direction==="sendrecv"){if(n.setDirection){n.setDirection("sendonly")}else{n.direction="sendonly"}}else if(n.direction==="recvonly"){if(n.setDirection){n.setDirection("inactive")}else{n.direction="inactive"}}}else if(r.offerToReceiveAudio===true&&!n){this.addTransceiver("audio")}if(typeof r.offerToReceiveVideo!=="undefined"){r.offerToReceiveVideo=!!r.offerToReceiveVideo}var i=this.getTransceivers().find(function(e){return e.receiver.track.kind==="video"});if(r.offerToReceiveVideo===false&&i){if(i.direction==="sendrecv"){if(i.setDirection){i.setDirection("sendonly")}else{i.direction="sendonly"}}else if(i.direction==="recvonly"){if(i.setDirection){i.setDirection("inactive")}else{i.direction="inactive"}}}else if(r.offerToReceiveVideo===true&&!i){this.addTransceiver("video")}}return t.apply(this,arguments)}}function m(e){if((typeof e==="undefined"?"undefined":n(e))!=="object"||e.AudioContext){return}e.AudioContext=e.webkitAudioContext}},{"../utils":15}],15:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:true});var n=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};r.extractVersion=s;r.wrapPeerConnectionEvent=c;r.disableLog=d;r.disableWarnings=f;r.log=p;r.deprecated=u;r.detectBrowser=l;r.compactObject=m;r.walkStats=h;r.filterStats=y;function i(e,t,r){if(t in e){Object.defineProperty(e,t,{value:r,enumerable:true,configurable:true,writable:true})}else{e[t]=r}return e}var a=true;var o=true;function s(e,t,r){var n=e.match(t);return n&&n.length>=r&&parseInt(n[r],10)}function c(e,t,r){if(!e.RTCPeerConnection){return}var n=e.RTCPeerConnection.prototype;var i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t){return i.apply(this,arguments)}var a=function e(t){var i=r(t);if(i&&n){if(n.handleEvent){n.handleEvent(i)}else{n(i)}}};this._eventMap=this._eventMap||{};if(!this._eventMap[t]){this._eventMap[t]=new Map}this._eventMap[t].set(n,a);return i.apply(this,[e,a])};var a=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t]){return a.apply(this,arguments)}if(!this._eventMap[t].has(r)){return a.apply(this,arguments)}var n=this._eventMap[t].get(r);this._eventMap[t].delete(r);if(this._eventMap[t].size===0){delete this._eventMap[t]}if(Object.keys(this._eventMap).length===0){delete this._eventMap}return a.apply(this,[e,n])};Object.defineProperty(n,"on"+t,{get:function e(){return this["_on"+t]},set:function e(r){if(this["_on"+t]){this.removeEventListener(t,this["_on"+t]);delete this["_on"+t]}if(r){this.addEventListener(t,this["_on"+t]=r)}},enumerable:true,configurable:true})}function d(e){if(typeof e!=="boolean"){return new Error("Argument type: "+(typeof e==="undefined"?"undefined":n(e))+". Please use a boolean.")}a=e;return e?"adapter.js logging disabled":"adapter.js logging enabled"}function f(e){if(typeof e!=="boolean"){return new Error("Argument type: "+(typeof e==="undefined"?"undefined":n(e))+". Please use a boolean.")}o=!e;return"adapter.js deprecation warnings "+(e?"disabled":"enabled")}function p(){if((typeof window==="undefined"?"undefined":n(window))==="object"){if(a){return}if(typeof console!=="undefined"&&typeof console.log==="function"){console.log.apply(console,arguments)}}}function u(e,t){if(!o){return}console.warn(e+" is deprecated, please use "+t+" instead.")}function l(e){var t={browser:null,version:null};if(typeof e==="undefined"||!e.navigator){t.browser="Not a browser.";return t}var r=e.navigator;if(r.mozGetUserMedia){t.browser="firefox";t.version=s(r.userAgent,/Firefox\/(\d+)\./,1)}else if(r.webkitGetUserMedia||e.isSecureContext===false&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer){t.browser="chrome";t.version=s(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2)}else if(r.mediaDevices&&r.userAgent.match(/Edge\/(\d+).(\d+)$/)){t.browser="edge";t.version=s(r.userAgent,/Edge\/(\d+).(\d+)$/,2)}else if(e.RTCPeerConnection&&r.userAgent.match(/AppleWebKit\/(\d+)\./)){t.browser="safari";t.version=s(r.userAgent,/AppleWebKit\/(\d+)\./,1);t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}else{t.browser="Not a supported browser.";return t}return t}function v(e){return Object.prototype.toString.call(e)==="[object Object]"}function m(e){if(!v(e)){return e}return Object.keys(e).reduce(function(t,r){var n=v(e[r]);var a=n?m(e[r]):e[r];var o=n&&!Object.keys(a).length;if(a===undefined||o){return t}return Object.assign(t,i({},r,a))},{})}function h(e,t,r){if(!t||r.has(t.id)){return}r.set(t.id,t);Object.keys(t).forEach(function(n){if(n.endsWith("Id")){h(e,e.get(t[n]),r)}else if(n.endsWith("Ids")){t[n].forEach(function(t){h(e,e.get(t),r)})}})}function y(e,t,r){var n=r?"outbound-rtp":"inbound-rtp";var i=new Map;if(t===null){return i}var a=[];e.forEach(function(e){if(e.type==="track"&&e.trackIdentifier===t.id){a.push(e)}});a.forEach(function(t){e.forEach(function(r){if(r.type===n&&r.trackId===t.id){h(e,r,i)}})});return i}},{}],16:[function(e,t,r){"use strict";var n=e("sdp");function i(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}function a(e,t,r,i,a){var o=n.writeRtpDescription(e.kind,t);o+=n.writeIceParameters(e.iceGatherer.getLocalParameters());o+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),r==="offer"?"actpass":a||"active");o+="a=mid:"+e.mid+"\r\n";if(e.rtpSender&&e.rtpReceiver){o+="a=sendrecv\r\n"}else if(e.rtpSender){o+="a=sendonly\r\n"}else if(e.rtpReceiver){o+="a=recvonly\r\n"}else{o+="a=inactive\r\n"}if(e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(i?i.id:"-")+" "+s+"\r\n";o+="a="+c;o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c;if(e.sendEncodingParameters[0].rtx){o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c;o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n"}}o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n";if(e.rtpSender&&e.sendEncodingParameters[0].rtx){o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"}return o}function o(e,t){var r=false;e=JSON.parse(JSON.stringify(e));return e.filter(function(e){if(e&&(e.urls||e.url)){var n=e.urls||e.url;if(e.url&&!e.urls){console.warn("RTCIceServer.url is deprecated! Use urls instead.")}var i=typeof n==="string";if(i){n=[n]}n=n.filter(function(e){var n=e.indexOf("turn:")===0&&e.indexOf("transport=udp")!==-1&&e.indexOf("turn:[")===-1&&!r;if(n){r=true;return true}return e.indexOf("stun:")===0&&t>=14393&&e.indexOf("?transport=udp")===-1});delete e.url;e.urls=i?n[0]:n;return!!n.length}})}function s(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]};var n=function(e,t){e=parseInt(e,10);for(var r=0;r<t.length;r++){if(t[r].payloadType===e||t[r].preferredPayloadType===e){return t[r]}}};var i=function(e,t,r,i){var a=n(e.parameters.apt,r);var o=n(t.parameters.apt,i);return a&&o&&a.name.toLowerCase()===o.name.toLowerCase()};e.codecs.forEach(function(n){for(var a=0;a<t.codecs.length;a++){var o=t.codecs[a];if(n.name.toLowerCase()===o.name.toLowerCase()&&n.clockRate===o.clockRate){if(n.name.toLowerCase()==="rtx"&&n.parameters&&o.parameters.apt){if(!i(n,o,e.codecs,t.codecs)){continue}}o=JSON.parse(JSON.stringify(o));o.numChannels=Math.min(n.numChannels,o.numChannels);r.codecs.push(o);o.rtcpFeedback=o.rtcpFeedback.filter(function(e){for(var t=0;t<n.rtcpFeedback.length;t++){if(n.rtcpFeedback[t].type===e.type&&n.rtcpFeedback[t].parameter===e.parameter){return true}}return false});break}}});e.headerExtensions.forEach(function(e){for(var n=0;n<t.headerExtensions.length;n++){var i=t.headerExtensions[n];if(e.uri===i.uri){r.headerExtensions.push(i);break}}});return r}function c(e,t,r){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(r)!==-1}function d(e,t){var r=e.getRemoteCandidates().find(function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type});if(!r){e.addRemoteCandidate(t)}return!r}function f(e,t){var r=new Error(t);r.name=e;r.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:undefined,OperationError:undefined}[e];return r}t.exports=function(e,t){function r(t,r){r.addTrack(t);r.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function p(t,r){r.removeTrack(t);r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}function u(t,r,n,i){var a=new Event("track");a.track=r;a.receiver=n;a.transceiver={receiver:n};a.streams=i;e.setTimeout(function(){t._dispatchEvent("track",a)})}var l=function(r){var i=this;var a=document.createDocumentFragment();["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){i[e]=a[e].bind(a)});this.canTrickleIceCandidates=null;this.needNegotiation=false;this.localStreams=[];this.remoteStreams=[];this._localDescription=null;this._remoteDescription=null;this.signalingState="stable";this.iceConnectionState="new";this.connectionState="new";this.iceGatheringState="new";r=JSON.parse(JSON.stringify(r||{}));this.usingBundle=r.bundlePolicy==="max-bundle";if(r.rtcpMuxPolicy==="negotiate"){throw f("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported")}else if(!r.rtcpMuxPolicy){r.rtcpMuxPolicy="require"}switch(r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all";break}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced";break}r.iceServers=o(r.iceServers||[],t);this._iceGatherers=[];if(r.iceCandidatePoolSize){for(var s=r.iceCandidatePoolSize;s>0;s--){this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}))}}else{r.iceCandidatePoolSize=0}this._config=r;this.transceivers=[];this._sdpSessionId=n.generateSessionId();this._sdpSessionVersion=0;this._dtlsRole=undefined;this._isClosed=false};Object.defineProperty(l.prototype,"localDescription",{configurable:true,get:function(){return this._localDescription}});Object.defineProperty(l.prototype,"remoteDescription",{configurable:true,get:function(){return this._remoteDescription}});l.prototype.onicecandidate=null;l.prototype.onaddstream=null;l.prototype.ontrack=null;l.prototype.onremovestream=null;l.prototype.onsignalingstatechange=null;l.prototype.oniceconnectionstatechange=null;l.prototype.onconnectionstatechange=null;l.prototype.onicegatheringstatechange=null;l.prototype.onnegotiationneeded=null;l.prototype.ondatachannel=null;l.prototype._dispatchEvent=function(e,t){if(this._isClosed){return}this.dispatchEvent(t);if(typeof this["on"+e]==="function"){this["on"+e](t)}};l.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)};l.prototype.getConfiguration=function(){return this._config};l.prototype.getLocalStreams=function(){return this.localStreams};l.prototype.getRemoteStreams=function(){return this.remoteStreams};l.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0;var n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:true};if(this.usingBundle&&r){n.iceTransport=this.transceivers[0].iceTransport;n.dtlsTransport=this.transceivers[0].dtlsTransport}else{var i=this._createIceAndDtlsTransports();n.iceTransport=i.iceTransport;n.dtlsTransport=i.dtlsTransport}if(!t){this.transceivers.push(n)}return n};l.prototype.addTrack=function(t,r){if(this._isClosed){throw f("InvalidStateError","Attempted to call addTrack on a closed peerconnection.")}var n=this.transceivers.find(function(e){return e.track===t});if(n){throw f("InvalidAccessError","Track already exists.")}var i;for(var a=0;a<this.transceivers.length;a++){if(!this.transceivers[a].track&&this.transceivers[a].kind===t.kind){i=this.transceivers[a]}}if(!i){i=this._createTransceiver(t.kind)}this._maybeFireNegotiationNeeded();if(this.localStreams.indexOf(r)===-1){this.localStreams.push(r)}i.track=t;i.stream=r;i.rtpSender=new e.RTCRtpSender(t,i.dtlsTransport);return i.rtpSender};l.prototype.addStream=function(e){var r=this;if(t>=15025){e.getTracks().forEach(function(t){r.addTrack(t,e)})}else{var n=e.clone();e.getTracks().forEach(function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",function(e){r.enabled=e.enabled})});n.getTracks().forEach(function(e){r.addTrack(e,n)})}};l.prototype.removeTrack=function(t){if(this._isClosed){throw f("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.")}if(!(t instanceof e.RTCRtpSender)){throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack "+"does not implement interface RTCRtpSender.")}var r=this.transceivers.find(function(e){return e.rtpSender===t});if(!r){throw f("InvalidAccessError","Sender was not created by this connection.")}var n=r.stream;r.rtpSender.stop();r.rtpSender=null;r.track=null;r.stream=null;var i=this.transceivers.map(function(e){return e.stream});if(i.indexOf(n)===-1&&this.localStreams.indexOf(n)>-1){this.localStreams.splice(this.localStreams.indexOf(n),1)}this._maybeFireNegotiationNeeded()};l.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(e){var r=t.getSenders().find(function(t){return t.track===e});if(r){t.removeTrack(r)}})};l.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})};l.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})};l.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0){return this.transceivers[0].iceGatherer}else if(this._iceGatherers.length){return this._iceGatherers.shift()}var i=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});Object.defineProperty(i,"state",{value:"new",writable:true});this.transceivers[t].bufferedCandidateEvents=[];this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||Object.keys(e.candidate).length===0;i.state=r?"completed":"gathering";if(n.transceivers[t].bufferedCandidateEvents!==null){n.transceivers[t].bufferedCandidateEvents.push(e)}};i.addEventListener("localcandidate",this.transceivers[t].bufferCandidates);return i};l.prototype._gather=function(t,r){var i=this;var a=this.transceivers[r].iceGatherer;if(a.onlocalcandidate){return}var o=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null;a.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates);a.onlocalcandidate=function(e){if(i.usingBundle&&r>0){return}var o=new Event("icecandidate");o.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate;var c=!s||Object.keys(s).length===0;if(c){if(a.state==="new"||a.state==="gathering"){a.state="completed"}}else{if(a.state==="new"){a.state="gathering"}s.component=1;s.ufrag=a.getLocalParameters().usernameFragment;var d=n.writeCandidate(s);o.candidate=Object.assign(o.candidate,n.parseCandidate(d));o.candidate.candidate=d;o.candidate.toJSON=function(){return{candidate:o.candidate.candidate,sdpMid:o.candidate.sdpMid,sdpMLineIndex:o.candidate.sdpMLineIndex,usernameFragment:o.candidate.usernameFragment}}}var f=n.getMediaSections(i._localDescription.sdp);if(!c){f[o.candidate.sdpMLineIndex]+="a="+o.candidate.candidate+"\r\n"}else{f[o.candidate.sdpMLineIndex]+="a=end-of-candidates\r\n"}i._localDescription.sdp=n.getDescription(i._localDescription.sdp)+f.join("");var p=i.transceivers.every(function(e){return e.iceGatherer&&e.iceGatherer.state==="completed"});if(i.iceGatheringState!=="gathering"){i.iceGatheringState="gathering";i._emitGatheringStateChange()}if(!c){i._dispatchEvent("icecandidate",o)}if(p){i._dispatchEvent("icecandidate",new Event("icecandidate"));i.iceGatheringState="complete";i._emitGatheringStateChange()}};e.setTimeout(function(){o.forEach(function(e){a.onlocalcandidate(e)})},0)};l.prototype._createIceAndDtlsTransports=function(){var t=this;var r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState();t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);n.ondtlsstatechange=function(){t._updateConnectionState()};n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:true});t._updateConnectionState()};return{iceTransport:r,dtlsTransport:n}};l.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;if(t){delete t.onlocalcandidate;delete this.transceivers[e].iceGatherer}var r=this.transceivers[e].iceTransport;if(r){delete r.onicestatechange;delete this.transceivers[e].iceTransport}var n=this.transceivers[e].dtlsTransport;if(n){delete n.ondtlsstatechange;delete n.onerror;delete this.transceivers[e].dtlsTransport}};l.prototype._transceive=function(e,r,i){var a=s(e.localCapabilities,e.remoteCapabilities);if(r&&e.rtpSender){a.encodings=e.sendEncodingParameters;a.rtcp={cname:n.localCName,compound:e.rtcpParameters.compound};if(e.recvEncodingParameters.length){a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc}e.rtpSender.send(a)}if(i&&e.rtpReceiver&&a.codecs.length>0){if(e.kind==="video"&&e.recvEncodingParameters&&t<15019){e.recvEncodingParameters.forEach(function(e){delete e.rtx})}if(e.recvEncodingParameters.length){a.encodings=e.recvEncodingParameters}else{a.encodings=[{}]}a.rtcp={compound:e.rtcpParameters.compound};if(e.rtcpParameters.cname){a.rtcp.cname=e.rtcpParameters.cname}if(e.sendEncodingParameters.length){a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc}e.rtpReceiver.receive(a)}};l.prototype.setLocalDescription=function(e){var t=this;if(["offer","answer"].indexOf(e.type)===-1){return Promise.reject(f("TypeError",'Unsupported type "'+e.type+'"'))}if(!c("setLocalDescription",e.type,t.signalingState)||t._isClosed){return Promise.reject(f("InvalidStateError","Can not set local "+e.type+" in state "+t.signalingState))}var r;var i;if(e.type==="offer"){r=n.splitSections(e.sdp);i=r.shift();r.forEach(function(e,r){var i=n.parseRtpParameters(e);t.transceivers[r].localCapabilities=i});t.transceivers.forEach(function(e,r){t._gather(e.mid,r)})}else if(e.type==="answer"){r=n.splitSections(t._remoteDescription.sdp);i=r.shift();var a=n.matchPrefix(i,"a=ice-lite").length>0;r.forEach(function(e,r){var o=t.transceivers[r];var c=o.iceGatherer;var d=o.iceTransport;var f=o.dtlsTransport;var p=o.localCapabilities;var u=o.remoteCapabilities;var l=n.isRejected(e)&&n.matchPrefix(e,"a=bundle-only").length===0;if(!l&&!o.rejected){var v=n.getIceParameters(e,i);var m=n.getDtlsParameters(e,i);if(a){m.role="server"}if(!t.usingBundle||r===0){t._gather(o.mid,r);if(d.state==="new"){d.start(c,v,a?"controlling":"controlled")}if(f.state==="new"){f.start(m)}}var h=s(p,u);t._transceive(o,h.codecs.length>0,false)}})}t._localDescription={type:e.type,sdp:e.sdp};if(e.type==="offer"){t._updateSignalingState("have-local-offer")}else{t._updateSignalingState("stable")}return Promise.resolve()};l.prototype.setRemoteDescription=function(i){var a=this;if(["offer","answer"].indexOf(i.type)===-1){return Promise.reject(f("TypeError",'Unsupported type "'+i.type+'"'))}if(!c("setRemoteDescription",i.type,a.signalingState)||a._isClosed){return Promise.reject(f("InvalidStateError","Can not set remote "+i.type+" in state "+a.signalingState))}var o={};a.remoteStreams.forEach(function(e){o[e.id]=e});var l=[];var v=n.splitSections(i.sdp);var m=v.shift();var h=n.matchPrefix(m,"a=ice-lite").length>0;var y=n.matchPrefix(m,"a=group:BUNDLE ").length>0;a.usingBundle=y;var g=n.matchPrefix(m,"a=ice-options:")[0];if(g){a.canTrickleIceCandidates=g.substr(14).split(" ").indexOf("trickle")>=0}else{a.canTrickleIceCandidates=false}v.forEach(function(c,f){var u=n.splitLines(c);var v=n.getKind(c);var g=n.isRejected(c)&&n.matchPrefix(c,"a=bundle-only").length===0;var C=u[0].substr(2).split(" ")[2];var S=n.getDirection(c,m);var T=n.parseMsid(c);var P=n.getMid(c)||n.generateIdentifier();if(g||v==="application"&&(C==="DTLS/SCTP"||C==="UDP/DTLS/SCTP")){a.transceivers[f]={mid:P,kind:v,protocol:C,rejected:true};return}if(!g&&a.transceivers[f]&&a.transceivers[f].rejected){a.transceivers[f]=a._createTransceiver(v,true)}var R;var b;var E;var _;var w;var k;var x;var M;var D;var O=n.parseRtpParameters(c);var I;var j;if(!g){I=n.getIceParameters(c,m);j=n.getDtlsParameters(c,m);j.role="client"}x=n.parseRtpEncodingParameters(c);var L=n.parseRtcpParameters(c);var A=n.matchPrefix(c,"a=end-of-candidates",m).length>0;var G=n.matchPrefix(c,"a=candidate:").map(function(e){return n.parseCandidate(e)}).filter(function(e){return e.component===1});if((i.type==="offer"||i.type==="answer")&&!g&&y&&f>0&&a.transceivers[f]){a._disposeIceAndDtlsTransports(f);a.transceivers[f].iceGatherer=a.transceivers[0].iceGatherer;a.transceivers[f].iceTransport=a.transceivers[0].iceTransport;a.transceivers[f].dtlsTransport=a.transceivers[0].dtlsTransport;if(a.transceivers[f].rtpSender){a.transceivers[f].rtpSender.setTransport(a.transceivers[0].dtlsTransport)}if(a.transceivers[f].rtpReceiver){a.transceivers[f].rtpReceiver.setTransport(a.transceivers[0].dtlsTransport)}}if(i.type==="offer"&&!g){R=a.transceivers[f]||a._createTransceiver(v);R.mid=P;if(!R.iceGatherer){R.iceGatherer=a._createIceGatherer(f,y)}if(G.length&&R.iceTransport.state==="new"){if(A&&(!y||f===0)){R.iceTransport.setRemoteCandidates(G)}else{G.forEach(function(e){d(R.iceTransport,e)})}}M=e.RTCRtpReceiver.getCapabilities(v);if(t<15019){M.codecs=M.codecs.filter(function(e){return e.name!=="rtx"})}k=R.sendEncodingParameters||[{ssrc:(2*f+2)*1001}];var N=false;if(S==="sendrecv"||S==="sendonly"){N=!R.rtpReceiver;w=R.rtpReceiver||new e.RTCRtpReceiver(R.dtlsTransport,v);if(N){var F;D=w.track;if(T&&T.stream==="-"){}else if(T){if(!o[T.stream]){o[T.stream]=new e.MediaStream;Object.defineProperty(o[T.stream],"id",{get:function(){return T.stream}})}Object.defineProperty(D,"id",{get:function(){return T.track}});F=o[T.stream]}else{if(!o.default){o.default=new e.MediaStream}F=o.default}if(F){r(D,F);R.associatedRemoteMediaStreams.push(F)}l.push([D,w,F])}}else if(R.rtpReceiver&&R.rtpReceiver.track){R.associatedRemoteMediaStreams.forEach(function(e){var t=e.getTracks().find(function(e){return e.id===R.rtpReceiver.track.id});if(t){p(t,e)}});R.associatedRemoteMediaStreams=[]}R.localCapabilities=M;R.remoteCapabilities=O;R.rtpReceiver=w;R.rtcpParameters=L;R.sendEncodingParameters=k;R.recvEncodingParameters=x;a._transceive(a.transceivers[f],false,N)}else if(i.type==="answer"&&!g){R=a.transceivers[f];b=R.iceGatherer;E=R.iceTransport;_=R.dtlsTransport;w=R.rtpReceiver;k=R.sendEncodingParameters;M=R.localCapabilities;a.transceivers[f].recvEncodingParameters=x;a.transceivers[f].remoteCapabilities=O;a.transceivers[f].rtcpParameters=L;if(G.length&&E.state==="new"){if((h||A)&&(!y||f===0)){E.setRemoteCandidates(G)}else{G.forEach(function(e){d(R.iceTransport,e)})}}if(!y||f===0){if(E.state==="new"){E.start(b,I,"controlling")}if(_.state==="new"){_.start(j)}}var U=s(R.localCapabilities,R.remoteCapabilities);var z=U.codecs.filter(function(e){return e.name.toLowerCase()==="rtx"}).length;if(!z&&R.sendEncodingParameters[0].rtx){delete R.sendEncodingParameters[0].rtx}a._transceive(R,S==="sendrecv"||S==="recvonly",S==="sendrecv"||S==="sendonly");if(w&&(S==="sendrecv"||S==="sendonly")){D=w.track;if(T){if(!o[T.stream]){o[T.stream]=new e.MediaStream}r(D,o[T.stream]);l.push([D,w,o[T.stream]])}else{if(!o.default){o.default=new e.MediaStream}r(D,o.default);l.push([D,w,o.default])}}else{delete R.rtpReceiver}}});if(a._dtlsRole===undefined){a._dtlsRole=i.type==="offer"?"active":"passive"}a._remoteDescription={type:i.type,sdp:i.sdp};if(i.type==="offer"){a._updateSignalingState("have-remote-offer")}else{a._updateSignalingState("stable")}Object.keys(o).forEach(function(t){var r=o[t];if(r.getTracks().length){if(a.remoteStreams.indexOf(r)===-1){a.remoteStreams.push(r);var n=new Event("addstream");n.stream=r;e.setTimeout(function(){a._dispatchEvent("addstream",n)})}l.forEach(function(e){var t=e[0];var n=e[1];if(r.id!==e[2].id){return}u(a,t,n,[r])})}});l.forEach(function(e){if(e[2]){return}u(a,e[0],e[1],[])});e.setTimeout(function(){if(!(a&&a.transceivers)){return}a.transceivers.forEach(function(e){if(e.iceTransport&&e.iceTransport.state==="new"&&e.iceTransport.getRemoteCandidates().length>0){console.warn("Timeout for addRemoteCandidate. Consider sending "+"an end-of-candidates notification");e.iceTransport.addRemoteCandidate({})}})},4e3);return Promise.resolve()};l.prototype.close=function(){this.transceivers.forEach(function(e){if(e.iceTransport){e.iceTransport.stop()}if(e.dtlsTransport){e.dtlsTransport.stop()}if(e.rtpSender){e.rtpSender.stop()}if(e.rtpReceiver){e.rtpReceiver.stop()}});this._isClosed=true;this._updateSignalingState("closed")};l.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)};l.prototype._maybeFireNegotiationNeeded=function(){var t=this;if(this.signalingState!=="stable"||this.needNegotiation===true){return}this.needNegotiation=true;e.setTimeout(function(){if(t.needNegotiation){t.needNegotiation=false;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}},0)};l.prototype._updateIceConnectionState=function(){var e;var t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};this.transceivers.forEach(function(e){if(e.iceTransport&&!e.rejected){t[e.iceTransport.state]++}});e="new";if(t.failed>0){e="failed"}else if(t.checking>0){e="checking"}else if(t.disconnected>0){e="disconnected"}else if(t.new>0){e="new"}else if(t.connected>0){e="connected"}else if(t.completed>0){e="completed"}if(e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}};l.prototype._updateConnectionState=function(){var e;var t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};this.transceivers.forEach(function(e){if(e.iceTransport&&e.dtlsTransport&&!e.rejected){t[e.iceTransport.state]++;t[e.dtlsTransport.state]++}});t.connected+=t.completed;e="new";if(t.failed>0){e="failed"}else if(t.connecting>0){e="connecting"}else if(t.disconnected>0){e="disconnected"}else if(t.new>0){e="new"}else if(t.connected>0){e="connected"}if(e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}};l.prototype.createOffer=function(){var r=this;if(r._isClosed){return Promise.reject(f("InvalidStateError","Can not call createOffer after close"))}var i=r.transceivers.filter(function(e){return e.kind==="audio"}).length;var o=r.transceivers.filter(function(e){return e.kind==="video"}).length;var s=arguments[0];if(s){if(s.mandatory||s.optional){throw new TypeError("Legacy mandatory/optional constraints not supported.")}if(s.offerToReceiveAudio!==undefined){if(s.offerToReceiveAudio===true){i=1}else if(s.offerToReceiveAudio===false){i=0}else{i=s.offerToReceiveAudio}}if(s.offerToReceiveVideo!==undefined){if(s.offerToReceiveVideo===true){o=1}else if(s.offerToReceiveVideo===false){o=0}else{o=s.offerToReceiveVideo}}}r.transceivers.forEach(function(e){if(e.kind==="audio"){i--;if(i<0){e.wantReceive=false}}else if(e.kind==="video"){o--;if(o<0){e.wantReceive=false}}});while(i>0||o>0){if(i>0){r._createTransceiver("audio");i--}if(o>0){r._createTransceiver("video");o--}}var c=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach(function(i,a){var o=i.track;var s=i.kind;var c=i.mid||n.generateIdentifier();i.mid=c;if(!i.iceGatherer){i.iceGatherer=r._createIceGatherer(a,r.usingBundle)}var d=e.RTCRtpSender.getCapabilities(s);if(t<15019){d.codecs=d.codecs.filter(function(e){return e.name!=="rtx"})}d.codecs.forEach(function(e){if(e.name==="H264"&&e.parameters["level-asymmetry-allowed"]===undefined){e.parameters["level-asymmetry-allowed"]="1"}if(i.remoteCapabilities&&i.remoteCapabilities.codecs){i.remoteCapabilities.codecs.forEach(function(t){if(e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate){e.preferredPayloadType=t.payloadType}})}});d.headerExtensions.forEach(function(e){var t=i.remoteCapabilities&&i.remoteCapabilities.headerExtensions||[];t.forEach(function(t){if(e.uri===t.uri){e.id=t.id}})});var f=i.sendEncodingParameters||[{ssrc:(2*a+1)*1001}];if(o){if(t>=15019&&s==="video"&&!f[0].rtx){f[0].rtx={ssrc:f[0].ssrc+1}}}if(i.wantReceive){i.rtpReceiver=new e.RTCRtpReceiver(i.dtlsTransport,s)}i.localCapabilities=d;i.sendEncodingParameters=f});if(r._config.bundlePolicy!=="max-compat"){c+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"}c+="a=ice-options:trickle\r\n";r.transceivers.forEach(function(e,t){c+=a(e,e.localCapabilities,"offer",e.stream,r._dtlsRole);c+="a=rtcp-rsize\r\n";if(e.iceGatherer&&r.iceGatheringState!=="new"&&(t===0||!r.usingBundle)){e.iceGatherer.getLocalCandidates().forEach(function(e){e.component=1;c+="a="+n.writeCandidate(e)+"\r\n"});if(e.iceGatherer.state==="completed"){c+="a=end-of-candidates\r\n"}}});var d=new e.RTCSessionDescription({type:"offer",sdp:c});return Promise.resolve(d)};l.prototype.createAnswer=function(){var r=this;if(r._isClosed){return Promise.reject(f("InvalidStateError","Can not call createAnswer after close"))}if(!(r.signalingState==="have-remote-offer"||r.signalingState==="have-local-pranswer")){return Promise.reject(f("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState))}var i=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);if(r.usingBundle){i+="a=group:BUNDLE "+r.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"}i+="a=ice-options:trickle\r\n";var o=n.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach(function(e,n){if(n+1>o){return}if(e.rejected){if(e.kind==="application"){if(e.protocol==="DTLS/SCTP"){i+="m=application 0 DTLS/SCTP 5000\r\n"}else{i+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n"}}else if(e.kind==="audio"){i+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\n"+"a=rtpmap:0 PCMU/8000\r\n"}else if(e.kind==="video"){i+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\n"+"a=rtpmap:120 VP8/90000\r\n"}i+="c=IN IP4 0.0.0.0\r\n"+"a=inactive\r\n"+"a=mid:"+e.mid+"\r\n";return}if(e.stream){var c;if(e.kind==="audio"){c=e.stream.getAudioTracks()[0]}else if(e.kind==="video"){c=e.stream.getVideoTracks()[0]}if(c){if(t>=15019&&e.kind==="video"&&!e.sendEncodingParameters[0].rtx){e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1}}}}var d=s(e.localCapabilities,e.remoteCapabilities);var f=d.codecs.filter(function(e){return e.name.toLowerCase()==="rtx"}).length;if(!f&&e.sendEncodingParameters[0].rtx){delete e.sendEncodingParameters[0].rtx}i+=a(e,d,"answer",e.stream,r._dtlsRole);if(e.rtcpParameters&&e.rtcpParameters.reducedSize){i+="a=rtcp-rsize\r\n"}});var c=new e.RTCSessionDescription({type:"answer",sdp:i});return Promise.resolve(c)};l.prototype.addIceCandidate=function(e){var t=this;var r;if(e&&!(e.sdpMLineIndex!==undefined||e.sdpMid)){return Promise.reject(new TypeError("sdpMLineIndex or sdpMid required"))}return new Promise(function(i,a){if(!t._remoteDescription){return a(f("InvalidStateError","Can not add ICE candidate without a remote description"))}else if(!e||e.candidate===""){for(var o=0;o<t.transceivers.length;o++){if(t.transceivers[o].rejected){continue}t.transceivers[o].iceTransport.addRemoteCandidate({});r=n.getMediaSections(t._remoteDescription.sdp);r[o]+="a=end-of-candidates\r\n";t._remoteDescription.sdp=n.getDescription(t._remoteDescription.sdp)+r.join("");if(t.usingBundle){break}}}else{var s=e.sdpMLineIndex;if(e.sdpMid){for(var c=0;c<t.transceivers.length;c++){if(t.transceivers[c].mid===e.sdpMid){s=c;break}}}var p=t.transceivers[s];if(p){if(p.rejected){return i()}var u=Object.keys(e.candidate).length>0?n.parseCandidate(e.candidate):{};if(u.protocol==="tcp"&&(u.port===0||u.port===9)){return i()}if(u.component&&u.component!==1){return i()}if(s===0||s>0&&p.iceTransport!==t.transceivers[0].iceTransport){if(!d(p.iceTransport,u)){return a(f("OperationError","Can not add ICE candidate"))}}var l=e.candidate.trim();if(l.indexOf("a=")===0){l=l.substr(2)}r=n.getMediaSections(t._remoteDescription.sdp);r[s]+="a="+(u.type?l:"end-of-candidates")+"\r\n";t._remoteDescription.sdp=n.getDescription(t._remoteDescription.sdp)+r.join("")}else{return a(f("OperationError","Can not add ICE candidate"))}}i()})};l.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var r=null;this.transceivers.forEach(function(e){if(e.rtpSender&&e.rtpSender.track===t){r=e.rtpSender}else if(e.rtpReceiver&&e.rtpReceiver.track===t){r=e.rtpReceiver}});if(!r){throw f("InvalidAccessError","Invalid selector.")}return r.getStats()}var n=[];this.transceivers.forEach(function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(t){if(e[t]){n.push(e[t].getStats())}})});return Promise.all(n).then(function(e){var t=new Map;e.forEach(function(e){e.forEach(function(e){t.set(e.id,e)})});return t})};var v=["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"];v.forEach(function(t){var r=e[t];if(r&&r.prototype&&r.prototype.getStats){var n=r.prototype.getStats;r.prototype.getStats=function(){return n.apply(this).then(function(e){var t=new Map;Object.keys(e).forEach(function(r){e[r].type=i(e[r]);t.set(r,e[r])});return t})}}});var m=["createOffer","createAnswer"];m.forEach(function(e){var t=l.prototype[e];l.prototype[e]=function(){var e=arguments;if(typeof e[0]==="function"||typeof e[1]==="function"){return t.apply(this,[arguments[2]]).then(function(t){if(typeof e[0]==="function"){e[0].apply(null,[t])}},function(t){if(typeof e[1]==="function"){e[1].apply(null,[t])}})}return t.apply(this,arguments)}});m=["setLocalDescription","setRemoteDescription","addIceCandidate"];m.forEach(function(e){var t=l.prototype[e];l.prototype[e]=function(){var e=arguments;if(typeof e[1]==="function"||typeof e[2]==="function"){return t.apply(this,arguments).then(function(){if(typeof e[1]==="function"){e[1].apply(null)}},function(t){if(typeof e[2]==="function"){e[2].apply(null,[t])}})}return t.apply(this,arguments)}});["getStats"].forEach(function(e){var t=l.prototype[e];l.prototype[e]=function(){var e=arguments;if(typeof e[1]==="function"){return t.apply(this,arguments).then(function(){if(typeof e[1]==="function"){e[1].apply(null)}})}return t.apply(this,arguments)}});return l}},{sdp:17}],17:[function(e,t,r){"use strict";var n={};n.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)};n.localCName=n.generateIdentifier();n.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})};n.splitSections=function(e){var t=e.split("\nm=");return t.map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})};n.getDescription=function(e){var t=n.splitSections(e);return t&&t[0]};n.getMediaSections=function(e){var t=n.splitSections(e);t.shift();return t};n.matchPrefix=function(e,t){return n.splitLines(e).filter(function(e){return e.indexOf(t)===0})};n.parseCandidate=function(e){var t;if(e.indexOf("a=candidate:")===0){t=e.substring(12).split(" ")}else{t=e.substring(10).split(" ")}var r={foundation:t[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(var n=8;n<t.length;n+=2){switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=parseInt(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1];r.usernameFragment=t[n+1];break;default:r[t[n]]=t[n+1];break}}return r};n.writeCandidate=function(e){var t=[];t.push(e.foundation);t.push(e.component);t.push(e.protocol.toUpperCase());t.push(e.priority);t.push(e.address||e.ip);t.push(e.port);var r=e.type;t.push("typ");t.push(r);if(r!=="host"&&e.relatedAddress&&e.relatedPort){t.push("raddr");t.push(e.relatedAddress);t.push("rport");t.push(e.relatedPort)}if(e.tcpType&&e.protocol.toLowerCase()==="tcp"){t.push("tcptype");t.push(e.tcpType)}if(e.usernameFragment||e.ufrag){t.push("ufrag");t.push(e.usernameFragment||e.ufrag)}return"candidate:"+t.join(" ")};n.parseIceOptions=function(e){return e.substr(14).split(" ")};n.parseRtpMap=function(e){var t=e.substr(9).split(" ");var r={payloadType:parseInt(t.shift(),10)};t=t[0].split("/");r.name=t[0];r.clockRate=parseInt(t[1],10);r.channels=t.length===3?parseInt(t[2],10):1;r.numChannels=r.channels;return r};n.writeRtpMap=function(e){var t=e.payloadType;if(e.preferredPayloadType!==undefined){t=e.preferredPayloadType}var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(r!==1?"/"+r:"")+"\r\n"};n.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}};n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&e.direction!=="sendrecv"?"/"+e.direction:"")+" "+e.uri+"\r\n"};n.parseFmtp=function(e){var t={};var r;var n=e.substr(e.indexOf(" ")+1).split(";");for(var i=0;i<n.length;i++){r=n[i].trim().split("=");t[r[0].trim()]=r[1]}return t};n.writeFmtp=function(e){var t="";var r=e.payloadType;if(e.preferredPayloadType!==undefined){r=e.preferredPayloadType}if(e.parameters&&Object.keys(e.parameters).length){var n=[];Object.keys(e.parameters).forEach(function(t){if(e.parameters[t]){n.push(t+"="+e.parameters[t])}else{n.push(t)}});t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t};n.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}};n.writeRtcpFb=function(e){var t="";var r=e.payloadType;if(e.preferredPayloadType!==undefined){r=e.preferredPayloadType}if(e.rtcpFeedback&&e.rtcpFeedback.length){e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})}return t};n.parseSsrcMedia=function(e){var t=e.indexOf(" ");var r={ssrc:parseInt(e.substr(7,t-7),10)};var n=e.indexOf(":",t);if(n>-1){r.attribute=e.substr(t+1,n-t-1);r.value=e.substr(n+1)}else{r.attribute=e.substr(t+1)}return r};n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(function(e){return parseInt(e,10)})}};n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t){return t.substr(6)}};n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}};n.getDtlsParameters=function(e,t){var r=n.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:r.map(n.parseFingerprint)}};n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";e.fingerprints.forEach(function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"});return r};n.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}};n.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+(typeof e.keyParams==="object"?n.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"};n.parseCryptoKeyParams=function(e){if(e.indexOf("inline:")!==0){return null}var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:undefined,mkiLength:t[2]?t[2].split(":")[1]:undefined}};n.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")};n.getCryptoParameters=function(e,t){var r=n.matchPrefix(e+t,"a=crypto:");return r.map(n.parseCryptoLine)};n.getIceParameters=function(e,t){var r=n.matchPrefix(e+t,"a=ice-ufrag:")[0];var i=n.matchPrefix(e+t,"a=ice-pwd:")[0];if(!(r&&i)){return null}return{usernameFragment:r.substr(12),password:i.substr(10)}};n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\n"+"a=ice-pwd:"+e.password+"\r\n"};n.parseRtpParameters=function(e){var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]};var r=n.splitLines(e);var i=r[0].split(" ");for(var a=3;a<i.length;a++){var o=i[a];var s=n.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(s){var c=n.parseRtpMap(s);var d=n.matchPrefix(e,"a=fmtp:"+o+" ");c.parameters=d.length?n.parseFmtp(d[0]):{};c.rtcpFeedback=n.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(n.parseRtcpFb);t.codecs.push(c);switch(c.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(c.name.toUpperCase());break;default:break}}}n.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(n.parseExtmap(e))});return t};n.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ";r+=t.codecs.length>0?"9":"0";r+=" UDP/TLS/RTP/SAVPF ";r+=t.codecs.map(function(e){if(e.preferredPayloadType!==undefined){return e.preferredPayloadType}return e.payloadType}).join(" ")+"\r\n";r+="c=IN IP4 0.0.0.0\r\n";r+="a=rtcp:9 IN IP4 0.0.0.0\r\n";t.codecs.forEach(function(e){r+=n.writeRtpMap(e);r+=n.writeFmtp(e);r+=n.writeRtcpFb(e)});var i=0;t.codecs.forEach(function(e){if(e.maxptime>i){i=e.maxptime}});if(i>0){r+="a=maxptime:"+i+"\r\n"}r+="a=rtcp-mux\r\n";if(t.headerExtensions){t.headerExtensions.forEach(function(e){r+=n.writeExtmap(e)})}return r};n.parseRtpEncodingParameters=function(e){var t=[];var r=n.parseRtpParameters(e);var i=r.fecMechanisms.indexOf("RED")!==-1;var a=r.fecMechanisms.indexOf("ULPFEC")!==-1;var o=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return e.attribute==="cname"});var s=o.length>0&&o[0].ssrc;var c;var d=n.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.substr(17).split(" ");return t.map(function(e){return parseInt(e,10)})});if(d.length>0&&d[0].length>1&&d[0][0]===s){c=d[0][1]}r.codecs.forEach(function(e){if(e.name.toUpperCase()==="RTX"&&e.parameters.apt){var r={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};if(s&&c){r.rtx={ssrc:c}}t.push(r);if(i){r=JSON.parse(JSON.stringify(r));r.fec={ssrc:s,mechanism:a?"red+ulpfec":"red"};t.push(r)}}});if(t.length===0&&s){t.push({ssrc:s})}var f=n.matchPrefix(e,"b=");if(f.length){if(f[0].indexOf("b=TIAS:")===0){f=parseInt(f[0].substr(7),10)}else if(f[0].indexOf("b=AS:")===0){f=parseInt(f[0].substr(5),10)*1e3*.95-50*40*8}else{f=undefined}t.forEach(function(e){e.maxBitrate=f})}return t};n.parseRtcpParameters=function(e){var t={};var r=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return e.attribute==="cname"})[0];if(r){t.cname=r.value;t.ssrc=r.ssrc}var i=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0;t.compound=i.length===0;var a=n.matchPrefix(e,"a=rtcp-mux");t.mux=a.length>0;return t};n.parseMsid=function(e){var t;var r=n.matchPrefix(e,"a=msid:");if(r.length===1){t=r[0].substr(7).split(" ");return{stream:t[0],track:t[1]}}var i=n.matchPrefix(e,"a=ssrc:").map(function(e){return n.parseSsrcMedia(e)}).filter(function(e){return e.attribute==="msid"});if(i.length>0){t=i[0].value.split(" ");return{stream:t[0],track:t[1]}}};n.parseSctpDescription=function(e){var t=n.parseMLine(e);var r=n.matchPrefix(e,"a=max-message-size:");var i;if(r.length>0){i=parseInt(r[0].substr(19),10)}if(isNaN(i)){i=65536}var a=n.matchPrefix(e,"a=sctp-port:");if(a.length>0){return{port:parseInt(a[0].substr(12),10),protocol:t.fmt,maxMessageSize:i}}var o=n.matchPrefix(e,"a=sctpmap:");if(o.length>0){var s=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:i}}};n.writeSctpDescription=function(e,t){var r=[];if(e.protocol!=="DTLS/SCTP"){r=["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]}else{r=["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"]}if(t.maxMessageSize!==undefined){r.push("a=max-message-size:"+t.maxMessageSize+"\r\n")}return r.join("")};n.generateSessionId=function(){return Math.random().toString().substr(2,21)};n.writeSessionBoilerplate=function(e,t,r){var i;var a=t!==undefined?t:2;if(e){i=e}else{i=n.generateSessionId()}var o=r||"thisisadapterortc";return"v=0\r\n"+"o="+o+" "+i+" "+a+" IN IP4 127.0.0.1\r\n"+"s=-\r\n"+"t=0 0\r\n"};n.writeMediaSection=function(e,t,r,i){var a=n.writeRtpDescription(e.kind,t);a+=n.writeIceParameters(e.iceGatherer.getLocalParameters());a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),r==="offer"?"actpass":"active");a+="a=mid:"+e.mid+"\r\n";if(e.direction){a+="a="+e.direction+"\r\n"}else if(e.rtpSender&&e.rtpReceiver){a+="a=sendrecv\r\n"}else if(e.rtpSender){a+="a=sendonly\r\n"}else if(e.rtpReceiver){a+="a=recvonly\r\n"}else{a+="a=inactive\r\n"}if(e.rtpSender){var o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o;a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o;if(e.sendEncodingParameters[0].rtx){a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o;a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n"}}a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n";if(e.rtpSender&&e.sendEncodingParameters[0].rtx){a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"}return a};n.getDirection=function(e,t){var r=n.splitLines(e);for(var i=0;i<r.length;i++){switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substr(2);default:}}if(t){return n.getDirection(t)}return"sendrecv"};n.getKind=function(e){var t=n.splitLines(e);var r=t[0].split(" ");return r[0].substr(2)};n.isRejected=function(e){return e.split(" ",2)[1]==="0"};n.parseMLine=function(e){var t=n.splitLines(e);var r=t[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}};n.parseOLine=function(e){var t=n.matchPrefix(e,"o=")[0];var r=t.substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}};n.isValidSDP=function(e){if(typeof e!=="string"||e.length===0){return false}var t=n.splitLines(e);for(var r=0;r<t.length;r++){if(t[r].length<2||t[r].charAt(1)!=="="){return false}}return true};if(typeof t==="object"){t.exports=n}},{}]},{},[1])(1)});
//# sourceMappingURL=adapter.map.js